<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
  <input type="text" id="input" >

</div>

</body>

<script>
    let obj  = {};
    let temp ={};
    Object.defineProperty(obj,'name',{
      get(){  //取obj name属性会触发
        return temp["name"]
      },
      set(val){  //给obj赋值会触发get方法
        console.log(val)
        temp["name"] = val;
        input.value = obj.name;
      }
    })

    input.value =obj.name;

    input.addEventListener('input',function () {
      obj.name = this.value;
    })

    // Object.defineProperty(obj,'name',{
    //   configurable:false, //是否可以删除
    //   writable:false, //是否可以重新赋值
    //   enumerable:false, //是否可以枚举
    //   value:1
    // });



</script>
</html>
